<?php 

include '../function.php';

$dsn = "mysql:host=localhost;dbname=student";
$username="root";
$password="";

try{
	$pdo = new Pdo($dsn,$username,$password);

        //创建异常模式
}catch(PDOException $e){

	die($e->getMessage());
}
// 设置警告
// $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING)

$pdo->query("SET NAMES 'utf8'");

$result = $pdo->query("select * from students where id = 4");
var_dump($result);
var_dump($result->fetchAll(PDO::FETCH_ASSOC));
 ?>